<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Extrude polygon by visual variables</title>
  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.0/esri/css/main.css">
  <script src="https://js.arcgis.com/4.0/"></script>

  <script>
    require([
      "esri/Map",
      "esri/views/SceneView",
      "esri/layers/FeatureLayer",
      "esri/symbols/PolygonSymbol3D",
      "esri/symbols/ExtrudeSymbol3DLayer",
      "esri/renderers/SimpleRenderer",
      "dojo/domReady!"
    ], function(Map, SceneView, FeatureLayer, PolygonSymbol3D,
      ExtrudeSymbol3DLayer, SimpleRenderer) {

      // Create map
      var map = new Map({
        basemap: "streets"
      });

      // Create SceneView for 3d visualization
      var view = new SceneView({
        container: "viewDiv",
        map: map,
        camera: {
          position: [-118.25, 4.27, 6249238],
          tilt: 30,
          heading: 23
        }
      });

      // Create featureLayer and add to the map
      var featureLayer = new FeatureLayer({
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer",
        layerId: 3
      });
      map.add(featureLayer);

      //Create the Renderer for the featureLayer,
      var extrudePolygonRenderer = new SimpleRenderer({
        symbol: new PolygonSymbol3D({
          symbolLayers: [new ExtrudeSymbol3DLayer()]
        }),
        visualVariables: [{
          type: "size",
          field: "POP07_SQMI",  // pop per square mile
          stops: [
            { value: 1, size: 40000 },  // 40km in height
            { value: 1000, size: 1000000 }  // 1,000km in height
          ]
        }, {
          type: "color",
          field: "POP07_SQMI",  // pop per square mile
          stops: [
            { value: 1, color: "white" },
            { value: 1000, color: "red" }
          ]
        }]
      });

      featureLayer.renderer = extrudePolygonRenderer;
    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>
</html>